/**
 * 
 */
package com.googlecode.pcapj.bridj;

import org.bridj.Pointer;
import org.bridj.StructObject;
import org.bridj.ann.Field;

/**
	struct timeval {
	    time_t      tv_sec;     // 秒 
	    suseconds_t tv_usec;    // マイクロ秒
	};
 */
public class timeval extends StructObject {
    public timeval() { super(); }
    public timeval(Pointer<? extends StructObject> pointer) { super(pointer); }

    /**
     * 
     * @return
     */
    @Field(0) 
    public int tv_sec() {
            return this.io.getIntField(this, 0);
    }
    
    /**
     * 
     * @param next
     * @return
     */
    @Field(0) 
    public timeval tv_sec(int tv_sec) {
            this.io.setIntField(this, 0, tv_sec);
            return this;
    }
    
    /**
     * 
     * @return
     */
    @Field(1) 
    public int suseconds_t() {
            return this.io.getIntField(this, 1);
    }
    /**
     * 
     * @param suseconds_t
     * @return
     */
    @Field(1) 
    public timeval suseconds_t(int suseconds_t) {
            this.io.setIntField(this, 1, suseconds_t);
            return this;
    }
    public long getTime(){
    	long suseconds_t = (0x00000000ffffffffL & this.suseconds_t())/1000;
    	long tv_sec = ((long)this.tv_sec()) * 1000;
    	return tv_sec + suseconds_t;
    }
}
